import { WL } from "./weilapb";

export enum WL_SettingID {
	SETTING_LOGIN_TOKEN, // token 一些上传需要用到的token数据
	SETTING_SESSION_LATEST_UPDATE, // 会话信息最后一次更新的时间
	SETTING_FRIEND_LATEST_UPDATE, // 好友最后一次更新时间
	SETTING_GROUP_LATEST_UPDATE, // 群组最后一次更新时间
	SETTING_SUB_USERINFO_VER_UPDATE,
	SETTING_MSG_SENDING_SEQ, // 发送消息的序号，不断地累加    
};

export type WL_Setting = {
    id: WL_SettingID;
    data: any;
};

export type WL_PttPayload = {
    frameCount: number;
    data: Uint8Array;
}


// common 
export const WL_UserStatusType = WL.Common.UserStatusType;
export type WL_UserStatus = WL.Common.IUserStatus;
export type WL_UserStatusInfo = WL.Common.IUserStatusInfo;
export const WL_UserType = WL.Common.UserType;
export type WL_UserInfo = WL.Common.IUserInfo & {
    pinyinName?: string | null;
};
export const WL_GenderType = WL.Common.GenderType;
export const WL_SessionType = WL.Common.SessionType;
export const WL_ClientType = WL.Common.ClientType;

// session
export enum WL_SessionStatus {
    SESSION_ACTIVATE,
    SESSION_DEACTIVATE,
    SESSION_INVALID
};
export const WL_BurstControlType = WL.Session.BurstControlType;
export const WL_MessageType = WL.Session.MessageType;
export enum WL_MsgDataType {
	WL_MSG_DATA_TEXT_TYPE,
	WL_MSG_DATA_AUDIO_TYPE,
	WL_MSG_DATA_IMAGE_TYPE,
	WL_MSG_DATA_VIDEO_TYPE,
	WL_MSG_DATA_FILE_TYPE,
	WL_MSG_DATA_LOCATION_TYPE,
	WL_MSG_DATA_COMMAND_TYPE,
	WL_MSG_DATA_PTT_TYPE,
	WL_MSG_DATA_SERVICE_TYPE,
	WL_MSG_DATA_SWITCH_TYPE,
	WL_MSG_DATA_WITHDRAW_TYPE,
	WL_MSG_DATA_UNKNOWN_TYPE
};
export enum WL_MsgDataStatus {
	WL_MSG_DATA_STATUS_NEW,
	WL_MSG_DATA_STATUS_SENT,
	WL_MSG_DATA_STATUS_UNSENT,
	WL_MSG_DATA_STATUS_READ,
	WL_MSG_DATA_STATUS_SENDING,
	WL_MSG_DATA_STATUS_WITHDRAW,
	WL_MSG_DATA_STATUS_ERR,
};

export type WL_CodecData = WL.Session.ICodecData;
export const WL_AudioSourceType = WL.Session.AudioSourceType;
export type WL_PttData = WL.Session.IPttData;
export type WL_AudioData = WL.Session.IAudioData & {
    frameCount?: number | null;
};
export type WL_SwitchData = WL.Session.ISwitchData;
export type WL_SessionInfo = WL.Session.ISessionInfo & {
    lastMsgData?: WL_MsgData |  null
};
export type WL_MediaData = {
    url?: string | null;
    thumb?: string | null;
    name?: string | null;
    size?: number | null;
};
export type WL_LocationData = {
    url: string | null;
    latitude: number | null;
    longitude: number | null;
    type: string | null;
    name: string | null;
    address: string | null;
    mapUrl: string | null;
};

export type WL_MsgData = WL.Session.IMsgData & {
    combo_id?: string | null;
    audioData?: WL_AudioData | null;
    fileInfo?: WL_MediaData | null;
    pictureData?: WL_MediaData | null;
    videoData?: WL_MediaData | null;
    locationData?: WL_LocationData | null;
    command?: string | null;
    status?: WL_MsgDataStatus | null;
};

export enum WL_NotificationType {
    SESSION_MSG_NOTIFICATION,
    LOGIN_KIKOUT_NOTIFICATION,
	FRIEND_INVITE_NOTIFICATION,
	FRIEND_ANSWER_NOTIFICATION,
	GROUP_INVITE_NOTIFICATION,
	GROUP_JOIN_NOTIFICATION,
	GROUP_ANSWER_INVITE_NOTIFICATION,
	GROUP_ANSWER_JOIN_NOTIFICATION,
    BUSINESS_SESSION_CHANGED_NOTIFICATION,
    BUSINESS_STAFF_INVITE_NOTIFICATION,
    BUSINESS_ANSWER_STAFF_INVITE_NOTIFICATION
};

export type WL_Notification = {
    id?: number | null;
    notificationType?: WL_NotificationType | null;
    data?: any | null;
    createTime?: number | null;
};


// login
export type WL_KickoutReason = WL.Login.KickoutReason;
export type WL_ExtensionState = WL.Login.ExtensionState;
export const WL_ExtensionType = WL.Login.ExtensionType;
export type WL_ExtensionInfo = WL.Login.IExtensionInfo;

// friend
export type WL_FriendInfo = WL.Friend.IFriendInfo;
export type WL_FriendInviteInfo = WL.Friend.IFriendInviteInfo;
export type WL_Friend = {
    friendInfo?: WL_FriendInfo | null,
    userInfo?: WL_UserInfo | null
};

// group
export const WL_GroupType = WL.Group.GroupType;
export const WL_GroupBurstType = WL.Group.GroupBurstType;
export const WL_GroupMemberType = WL.Group.GroupMemberType
export const WL_GroupPublicType = WL.Group.GroupPublicType;
export const WL_GroupAuthType = WL.Group.GroupAuthType;
export const WL_GroupSearchType = WL.Group.GroupSearchType;
export type WL_GroupVersionInfo = WL.Group.IGroupVersionInfo;
export type WL_GroupAttribute = WL.Group.IGroupAttribute & {
    groupClass?: number | null
};

export type WL_GroupMemberInfo = WL.Group.IGroupMemberInfo & {
    combo_gid_uid?: string | null
};
export type WL_GroupMember = {
    memberInfo?: WL_GroupMemberInfo | null,
    userInfo?: WL_UserInfo | null
};

export type WL_GroupNoticeInfo = WL.Group.IGroupNoticeInfo;
export type WL_GroupInviteInfo = WL.Group.IGroupInviteInfo;
export type WL_GroupJoinInfo = WL.Group.IGroupJoinInfo;
export type WL_GroupBroadcastInfo = WL.Group.IGroupBroadcastInfo;
export const WL_GroupMemberChangeType = WL.Group.GroupMemberChangeType;
export type WL_GroupMemberChangeLog = WL.Group.IGroupMemberChangeLog;

// business
export const WL_ServiceType = WL.Business.ServiceType;
export type WL_ServiceAttribute = WL.Business.IServiceAttribute;
export type WL_ServiceStaffStatus = WL.Business.ServiceStaffStatus;
export type WL_StaffAttribute = WL.Business.IStaffAttribute;
export type WL_StaffInvite = WL.Business.IStaffInvite;
export type WL_ServiceStatus = WL.Business.ServiceStatus;
export type WL_CustomerAttribute = WL.Business.ICustomerAttribute;
export type WL_ServiceSession = WL.Business.IServiceSession;
export type WL_ServiceSessionInvite = WL.Business.IServiceSessionInvite;

// location
export type WL_LocationSessionInfo = WL.Location.ILocationSessionInfo;
export type WL_LocationParam = WL.Location.ILocationParam;
export const WL_LocationType = WL.Location.LocationType;
export const WL_LocationExtensionType = WL.Location.LocationExtensionType;
export type WL_LocationInfo = WL.Location.ILocationInfo;
export type WL_LocationControl = WL.Location.ILocationControl;


export const ResultCodeMsg = new Map([
    [WL.Service.ResultCode.RESULT_SUCCESS, 'success'],
    [WL.Service.ResultCode.RESULT_FAILURE, 'failure'],
    [WL.Service.ResultCode.RESULT_DISCONNECT, 'disconnect'],
    [WL.Service.ResultCode.RESULT_NO_MSG_SERVER, 'no msg server'],
    [WL.Service.ResultCode.RESULT_NO_DB_SERVER, 'no db server'],
    [WL.Service.ResultCode.RESULT_NO_CACHE_SERVER, 'no cache server'],
    [WL.Service.ResultCode.RESULT_NO_LOGIN_SERVER, 'no login server'],
    [WL.Service.ResultCode.RESULT_NO_ROUTE_SERVER, 'no route server'],
    [WL.Service.ResultCode.RESULT_DB_EXCEPTION, 'db exception'],
    [WL.Service.ResultCode.RESULT_CACHE_EXCEPTION, 'cache exception'],
    [WL.Service.ResultCode.RESULT_SERVER_MAINTENANCE, 'server maintenance'],
    [WL.Service.ResultCode.RESULT_SERVER_EXCEPTION, 'server exception'],
    [WL.Service.ResultCode.RESULT_PARAM_INVALID, 'param invalid'],
    [WL.Service.ResultCode.RESULT_REQUEST_NOT_SUPPORT, 'request not support'],
    [WL.Service.ResultCode.RESULT_REQUEST_LIMITED, 'request limited'],
    [WL.Service.ResultCode.RESULT_REQUEST_INVALID, 'request invalid'],
    [WL.Service.ResultCode.RESULT_VERSION_TOO_OLD, 'version too old'],
    [WL.Service.ResultCode.RESULT_BLACKLIST_LIMITED, 'blacklist limited'],
    [WL.Service.ResultCode.RESULT_AUTH_INVALID, 'auth invalid'],
    [WL.Service.ResultCode.RESULT_PERMIT_LIMITED, 'permit limited'],
    [WL.Service.ResultCode.RESULT_DATA_NOT_EXIST, 'data not exist'],
    [WL.Service.ResultCode.RESULT_DATA_INVALID, 'data invalid'],
    [WL.Service.ResultCode.RESULT_VERIFICATION_CODE_ERROR, 'verification code error'],
    [WL.Service.ResultCode.RESULT_TOKEN_INVALID, 'token invalid'],
    [WL.Service.ResultCode.RESULT_REQUEST_FREQUENTLY, 'request frequently'],
    [WL.Service.ResultCode.RESULT_NUMBER_RESOURCE_USE_UP, 'number resource use up'],
    [WL.Service.ResultCode.RESULT_REQUEST_TIMEOUT, 'request timeout'],
    [WL.Service.ResultCode.RESULT_TRANSMIT_TIMEOUT, 'transmit timeout'],
    [WL.Service.ResultCode.RESULT_APP_ILLEGAL, 'app illegal'],
    [WL.Service.ResultCode.RESULT_PHONE_DUPLICATE, 'phone duplicate'],
    [WL.Service.ResultCode.RESULT_PHONE_INVALID, 'phone invalid'],
    [WL.Service.ResultCode.RESULT_PHONE_HAS_BEEN_BANNED, 'phone has been banned'],
    [WL.Service.ResultCode.RESULT_PASSWORD_ERROR, 'password error'],
    [WL.Service.ResultCode.RESULT_SEND_VERIFICATION_CODE_FAIL, 'send verification code fail'],
    [WL.Service.ResultCode.RESULT_CONTENT_AUDIT_BLOCK, 'content audit block'],
    [WL.Service.ResultCode.RESULT_BALANCE_INSUFFICIENT, 'balance insufficient'],
    [WL.Service.ResultCode.RESULT_LOGIN_FORBID_IP, 'login forbid ip'],
    [WL.Service.ResultCode.RESULT_LOGIN_FORBID_USER, 'login forbid user'],
    [WL.Service.ResultCode.RESULT_LOGIN_PASSWORD_ERROR_TOO_TIMES, 'login password error too times'],
    [WL.Service.ResultCode.RESULT_LOGIN_SYSTEM_FULL, 'login system full'],
    [WL.Service.ResultCode.RESULT_LOGIN_VERIFYCODE_INVALID, 'login verifycode invalid'],
    [WL.Service.ResultCode.RESULT_LOGIN_ACCOUNT_OR_PASSWD_ERROR, 'login account or passwd error'],
    [WL.Service.ResultCode.RESULT_LOGIN_EXTENSION_HAS_BIND, 'login extension has bind'],
    [WL.Service.ResultCode.RESULT_LOGIN_EXTENSION_BINDING, 'login extension binding'],
    [WL.Service.ResultCode.RESULT_LOGIN_EXTENSION_NOT_BIND, 'login extension not bind'],
    [WL.Service.ResultCode.RESULT_LOGIN_EXTENSION_LAWLESSNESS, 'login extension lawlessness'],
    [WL.Service.ResultCode.RESULT_LOGIN_EXTENSION_LICENSE_LIMITED, 'login extension license limited'],
    [WL.Service.ResultCode.RESULT_LOGIN_EXTENSION_ACCOUNT_ERROR, 'login extension account error'],
    [WL.Service.ResultCode.RESULT_LOGIN_EXTENSION_PASSWORD_ERROR, 'login extension password error'],
    [WL.Service.ResultCode.RESULT_LOGIN_EXTENSION_OFFLINE, 'login extension offline'],
    [WL.Service.ResultCode.RESULT_USER_NOT_EXIST, 'user not exist'],
    [WL.Service.ResultCode.RESULT_USER_PERIPHERAL_UNAUTHORIZED, 'user peripheral unauthorized'],
    [WL.Service.ResultCode.RESULT_USER_PERIPHERAL_REPLICATED, 'user peripheral replicated'],
    [WL.Service.ResultCode.RESULT_USER_PERIPHERAL_MULTIDEVICE, 'user peripheral multidevice'],
    [WL.Service.ResultCode.RESULT_USER_OFFLINE, 'user offline'],
    [WL.Service.ResultCode.RESULT_FRIEND_NOT_FRIEND, 'friend not friend'],
    [WL.Service.ResultCode.RESULT_FRIEND_INVITE_NOT_EXIST, 'friend invite not exist'],
    [WL.Service.ResultCode.RESULT_FRIEND_IS_BLACKLIST, 'friend is blacklist'],
    [WL.Service.ResultCode.RESULT_FRIEND_SHIELD_OPEN, 'friend shield open'],
    [WL.Service.ResultCode.RESULT_GROUP_NOT_EXIST, 'group not exist'],
    [WL.Service.ResultCode.RESULT_GROUP_ACCESS_LIMITED, 'group access limited'],
    [WL.Service.ResultCode.RESULT_GROUP_YOU_ARE_NOT_OWNER, 'group you are not owner'],
    [WL.Service.ResultCode.RESULT_GROUP_YOU_ARE_NOT_ADMIN, 'group you are not admin'],
    [WL.Service.ResultCode.RESULT_GROUP_MEMBERS_FULL, 'group members full'],
    [WL.Service.ResultCode.RESULT_GROUP_NUMBER_USEUP, 'group number useup'],
    [WL.Service.ResultCode.RESULT_GROUP_BROADCAST_EXIST, 'group broadcast exist'],
    [WL.Service.ResultCode.RESULT_GROUP_BROADCAST_NOEXIST, 'group broadcast noexist'],
    [WL.Service.ResultCode.RESULT_GROUP_PASSWORD_ERROR, 'group password error'],
    [WL.Service.ResultCode.RESULT_GROUP_OWNER_FULL, 'group owner full'],
    [WL.Service.ResultCode.RESULT_GROUP_BURST_OCCUPY, 'group burst occupy'],
    [WL.Service.ResultCode.RESULT_GROUP_USER_NOT_MEMBER, 'group user not member'],
    [WL.Service.ResultCode.RESULT_GROUP_MEMBER_LIMIT_MAX, 'group member limit max'],
    [WL.Service.ResultCode.RESULT_GROUP_MEMBER_IS_ADMIN, 'group member is admin'],
    [WL.Service.ResultCode.RESULT_GROUP_USER_IN_BLACKLIST, 'group user in blacklist'],
    [WL.Service.ResultCode.RESULT_GROUP_OWNER_CANNOT_EXIT, 'group owner cannot exit'],
    [WL.Service.ResultCode.RESULT_GROUP_YOU_ARE_SHUTUP, 'group you are shutup'],
    [WL.Service.ResultCode.RESULT_GROUP_MEMBER_SHUTUP, 'group member shutup'],
    [WL.Service.ResultCode.RESULT_GROUP_MEMBER_IS_OWNER, 'group member is owner'],
    [WL.Service.ResultCode.RESULT_GROUP_BURST_REVOKE, 'group burst revoke'],
    [WL.Service.ResultCode.RESULT_GROUP_MEMBER_IS_EXTENSION, 'group member is extension'],
    [WL.Service.ResultCode.RESULT_GROUP_COUNT_LIMIT, 'group count limit'],
    [WL.Service.ResultCode.RESULT_GROUP_MEMBER_HAS_EXTENSION, 'group member has extension'],
    [WL.Service.ResultCode.RESULT_GROUP_OWNER_CANNOT_EXTENSION, 'group owner cannot extension'],
    [WL.Service.ResultCode.RESULT_GROUP_SUB_USER_GROUP_COUNT_LIMIT, 'group sub user group count limit'],
    [WL.Service.ResultCode.RESULT_SESSION_BURST_MONITOR, 'session burst monitor'],
    [WL.Service.ResultCode.RESULT_SESSION_VOIP_BUSY, 'session voip busy'],
    [WL.Service.ResultCode.RESULT_SESSION_VOIP_INTERRUPT, 'session voip interrupt'],
    [WL.Service.ResultCode.RESULT_ROOM_HAS_EXIST, 'room has exist'],
    [WL.Service.ResultCode.RESULT_ROOM_NOT_EXIST, 'room not exist'],
    [WL.Service.ResultCode.RESULT_ROOM_LOCK, 'room lock'],
    [WL.Service.ResultCode.RESULT_ROOM_SPEAKING, 'room speaking'],
    [WL.Service.ResultCode.RESULT_ROOM_CHANGE_CHARGE_LIMITED, 'room change charge limited'],
    [WL.Service.ResultCode.RESULT_ROOM_HONORED_GUEST_PERMIT, 'room honored guest permit'],
    [WL.Service.ResultCode.RESULT_ROOM_NOT_ENTRY, 'room not entry'],
    [WL.Service.ResultCode.RESULT_ROOM_YOU_ARE_HONORED_GUEST, 'room you are honored guest'],
    [WL.Service.ResultCode.RESULT_ROOM_HONORED_GUEST_FULL, 'room honored guest full'],
    [WL.Service.ResultCode.RESULT_BUSINESS_SERVICE_CLOSED, 'business service closed'],
    [WL.Service.ResultCode.RESULT_BUSINESS_STAFF_NOT_ADMIN, 'business staff not admin'],
    [WL.Service.ResultCode.RESULT_BUSINESS_STAFF_INVALID, 'business staff invalid'],
    [WL.Service.ResultCode.RESULT_BUSINESS_STAFF_NOT_ONLINE, 'business staff not online'],
    [WL.Service.ResultCode.RESULT_BUSINESS_STAFF_BUSY, 'business staff busy'],
    [WL.Service.ResultCode.RESULT_BUSINESS_STAFF_DUPLICATE, 'business staff duplicate'],
    [WL.Service.ResultCode.RESULT_BUSINESS_SESSION_NOT_EXIST, 'business session not exist'],
    [WL.Service.ResultCode.RESULT_BUSINESS_SESSION_PROCESSING, 'business session processing'],
    [WL.Service.ResultCode.RESULT_BUSINESS_SESSION_STAFF_INVALID, 'business session staff invalid'],
    [WL.Service.ResultCode.RESULT_BUSINESS_SESSION_REMOVE_SELF_LIMIT, 'business session remove self limit'],
    [WL.Service.ResultCode.RESULT_BUSINESS_ORDER_NOT_EXIST, 'business order not exist'],
    [WL.Service.ResultCode.RESULT_BUSINESS_ORDER_INVALID, 'business order invalid']
])
